from django.shortcuts import render
from django.views import View
from tools.utils import get_category
from contents.models import ContentCategory
import pprint
# Create your views here.
class IndexView(View):
    def get(self,request):
        # 从封装的工具模块中获取导航菜单
        categories = get_category()
        # 首页其他广告数据的获取
        contents = {}

        content_category = ContentCategory.objects.all()
        for cat in content_category:
            # 通过当前的广告分类对象查询到对应的所有广告数据
            contents[cat.key] = cat.content_set.filter(status=True).order_by('sequence')

        # pprint.pprint(contents)
        return render(request,'index.html',locals())
